package com.huilian.iotbox.admin.controller;

import com.huilian.iotbox.admin.service.MoneyDetailsService;
import com.huilian.iotbox.admin.service.UserService;
import com.huilian.iotbox.data.common.ServerResponse;
import com.huilian.iotbox.data.controller.BaseController;
import com.huilian.iotbox.data.dto.MoneyDetailsDto;
import com.huilian.iotbox.data.vo.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author 龙 路 飞
 * @CreateDate: 2021-09-27 16:22
 * @Description:
 */
@RestController
@RequestMapping("/api/moneyDetails")
public class MoneyDetailsController extends BaseController {
    @Autowired
    private MoneyDetailsService moneyDetailsService;

    @Resource
    private UserService userService;

    @PostMapping("/findList")
    public ServerResponse findList(@RequestBody MoneyDetailsDto moneyDetailsDto, HttpServletRequest request){
        UserInfo userInfo = userService.getLoginUserInfo(request);
        moneyDetailsDto.setUserInfo(userInfo);
        moneyDetailsDto.setPageNum(Integer.parseInt(request.getParameter("pageNum")));
        moneyDetailsDto.setPageSize(Integer.parseInt(request.getParameter("pageSize")));
        return ServerResponse.createBySuccess(moneyDetailsService.findList(moneyDetailsDto));
    }
}
